﻿using System;
using System.Windows.Media;
using Socium.Domain.Tests.Sociometric;
using Socium.Presentation;

namespace Socium.Testings.Sociometric {
	class ElectionCriteriaViewModel : ViewModelBase {
		readonly ProcedureViewModel _procedure_view_model;
		readonly ElectionCriteria _election_criteria;

		public ElectionCriteriaViewModel(ProcedureViewModel procedure_view_model, ElectionCriteria election_criteria) {
			_procedure_view_model = procedure_view_model;
			_election_criteria = election_criteria;
		}

		public bool IsSelected {
			get { return _procedure_view_model.SelectedCriteria == this; }
			set {
				if (value) {
					_procedure_view_model.SelectedCriteria = this;
				}
			}
		}

		Color _color;
		public Color Color {
			get { return _color; }
			set { 
				_color = value;
				Brush = new SolidColorBrush(value);

				OnPropertyChanged("Color");
				OnPropertyChanged("Brush");

				var handler = ColorChanged;
				if (handler != null) {
					handler(this, EventArgs.Empty);
				}
			}
		}

		public Brush Brush { get; private set; }

		public ElectionCriteria ElectionCriteria {
			get { return _election_criteria; }
		}

		public event EventHandler ColorChanged;
	}
}
